package com.ruoyi.jiajia.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JiajiaWorkerBankCard;
import com.ruoyi.system.service.IJiajiaWorkerBankCardService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 社工银行卡Controller
 * 
 * @author ruoyi
 * @date 2021-11-01
 */
@Controller
@RequestMapping("/jiajia/bankCard")
public class JiajiaWorkerBankCardController extends BaseController
{
    private String prefix = "jiajia/bankCard";

    @Autowired
    private IJiajiaWorkerBankCardService jiajiaWorkerBankCardService;

    @RequiresPermissions("jiajia:bankCard:view")
    @GetMapping()
    public String bankCard()
    {
        return prefix + "/bankCard";
    }

    /**
     * 查询社工银行卡列表
     */
    @RequiresPermissions("jiajia:bankCard:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JiajiaWorkerBankCard jiajiaWorkerBankCard)
    {
        startPage();
        List<JiajiaWorkerBankCard> list = jiajiaWorkerBankCardService.selectJiajiaWorkerBankCardList(jiajiaWorkerBankCard);
        return getDataTable(list);
    }

    /**
     * 导出社工银行卡列表
     */
    @RequiresPermissions("jiajia:bankCard:export")
    @Log(title = "社工银行卡", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JiajiaWorkerBankCard jiajiaWorkerBankCard)
    {
        List<JiajiaWorkerBankCard> list = jiajiaWorkerBankCardService.selectJiajiaWorkerBankCardList(jiajiaWorkerBankCard);
        ExcelUtil<JiajiaWorkerBankCard> util = new ExcelUtil<JiajiaWorkerBankCard>(JiajiaWorkerBankCard.class);
        return util.exportExcel(list, "社工银行卡数据");
    }

    /**
     * 新增社工银行卡
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存社工银行卡
     */
    @RequiresPermissions("jiajia:bankCard:add")
    @Log(title = "社工银行卡", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JiajiaWorkerBankCard jiajiaWorkerBankCard)
    {
        return toAjax(jiajiaWorkerBankCardService.insertJiajiaWorkerBankCard(jiajiaWorkerBankCard));
    }

    /**
     * 修改社工银行卡
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JiajiaWorkerBankCard jiajiaWorkerBankCard = jiajiaWorkerBankCardService.selectJiajiaWorkerBankCardById(id);
        mmap.put("jiajiaWorkerBankCard", jiajiaWorkerBankCard);
        return prefix + "/edit";
    }

    /**
     * 修改保存社工银行卡
     */
    @RequiresPermissions("jiajia:bankCard:edit")
    @Log(title = "社工银行卡", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JiajiaWorkerBankCard jiajiaWorkerBankCard)
    {
        return toAjax(jiajiaWorkerBankCardService.updateJiajiaWorkerBankCard(jiajiaWorkerBankCard));
    }

    /**
     * 删除社工银行卡
     */
    @RequiresPermissions("jiajia:bankCard:remove")
    @Log(title = "社工银行卡", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jiajiaWorkerBankCardService.deleteJiajiaWorkerBankCardByIds(ids));
    }
}
